from tools_algorithm import *


class Solution:
    def maxScoreSightseeingPair(self, values: List[int]) -> int:
        def max(a, b):
            return a if a >= b else b

        ans = -inf
        mx = -inf
        for i, v in enumerate(values):
            c = v + i
            ans = max(ans, mx + v - i)
            mx = max(mx, c)

        return ans
